package com.noble.meether.fragment.mail.bean;

import com.noble.library.base.bean.BaseData;
import com.noble.meether.fragment.mail.store.MsgListTable;

import org.json.JSONObject;

/**
 * 私聊用户列表
 */
public class UserMessage extends BaseData {
    private long whisperID;    // 私聊ID
    private String nickName;  // 聊天用户昵称
    private String avatar;    // 聊天用户头像
    private int vipStatus;    // vip状态

    private String content;     // 最新消息内容
    private long updateTime;  // 更新时间

    private int msgUnreadNum;    // 未读消息数；供本地消息列表排序使用

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.whisperID = jsonObject.optLong(MsgListTable.COLUMN_ID);
        this.nickName = jsonObject.optString(MsgListTable.COLUMN_NAME);
        this.avatar = jsonObject.optString(MsgListTable.COLUMN_AVATAR);
        this.vipStatus = jsonObject.optInt(MsgListTable.COLUMN_VIP);
        this.content = jsonObject.optString(MsgListTable.COLUMN_CONTENT);
        this.updateTime = jsonObject.optLong(MsgListTable.COLUMN_TIME);
    }

    public int getMsgUnreadNum() {
        return msgUnreadNum;
    }

    public void setMsgUnreadNum(int msgUnreadNum) {
        this.msgUnreadNum = msgUnreadNum;
    }

    /**
     * 判断是否是vip
     */
    public boolean isVip() {
        return vipStatus == 1 || vipStatus == 2;
    }

    public long getWhisperID() {
        return whisperID;
    }

    public String getSWhisperID() {
        return String.valueOf(whisperID);
    }

    public String getNickName() {
        return nickName;
    }

    public String getAvatar() {
        return avatar;
    }

    public int getVipStatus() {
        return vipStatus;
    }

    public String getContent() {
        return content;
    }

    public long getUpdateTime() {
        return updateTime;
    }

    public void setWhisperID(long whisperID) {
        this.whisperID = whisperID;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public void setVipStatus(int vipStatus) {
        this.vipStatus = vipStatus;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }
}